public class PositionNewEditOverrideExtension{
    // This simple extension is to demonstrate overriding the save function, and how to determine if the record
    //   should be updated or inserted during the save operation.  This extension could be used on both
    //   an Edit override and a New override simultaneously.
    
    // TODO: Declare a variable to hold the position.
    public position__c pos {get;set;}
    // TODO: Declare a Boolean variable to track if this is an insert or an update.
    public boolean isInsert;

    // Declare standardController controller
    private ApexPages.StandardController controller;

    // Declare a string property to hold a message value
    public String myMessage { get; set; }

    
    // TODO: Write the extension constructor and initialize the member position variable by using a method on the standard controller.
    public PositionNewEditOverrideExtension(ApexPages.StandardController sc) {
    	controller = sc;
    	this.pos = (Position__c) controller.getRecord();
    	isInsert = (pos.id == null) ? true : false;
    }
    
    // This function is called from a commandButton on the page
    public PageReference SayHelloWorld(){
        // call this custom function from your visualforce page
        myMessage = 'Hello World!';

        // We're not redirecting the user to a different page so we just say return null
        return null;
    }
    
    public PageReference mysave(){
    	if (isInsert) {
    		insert pos;
    		controller = new ApexPages.StandardController(pos);
    	} else {
    		update pos;	
    	}
        return controller.view();

    }
   
}